﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace GameEditor
{
    /// <summary>
    /// 通用编辑器进度条
    /// author:dingjie
    /// </summary>
    public class EditorProgressBar : IShowProgressBar
    {

        int cur = 0;

        int max = 0;

        string title = "title";

        string context = "";

        public EditorProgressBar(int max)
        {

            this.max = max;
        }

        public EditorProgressBar(int max,string title,string context){
            this.max = max;
            this.title = title;
            this.context = context;
        }

        public string GetContent()
        {
            return string.Format(Context + "当前进度{0}/{1}", cur, max);
        }

        public float GetProgress()
        {
            if (max == 0)
                return 0;
            return 1f * cur / max;
        }

        public string GetTitle()
        {
            return Title;
        }

        public bool IsFinish()
        {
            return cur == max;
        }

        public int Cur
        {
            get
            {
                return this.cur;
            }
            set
            {
                cur = value;
            }
        }

        public string Title
        {
            get
            {
                return title;
            }

            set
            {
                title = value;
            }
        }

        public string Context
        {
            get
            {
                return context;
            }

            set
            {
                context = value;
            }
        }
    }

}
